import React, { Component } from 'react';
import PropTypes from 'prop-types';

export default class Counter extends Component {
  componentDidMount() {}

  render() {
    const {
      count,
      increment,
      decrement,
      reset,
      getUserInfo,
      userInfo,
    } = this.props;
    console.log('counter', count, userInfo);
    return (
      <div>
        <div>{`当前计数为:${count}`}</div>
        <button
          type="button"
          onClick={() => increment()}
        >
          自增
        </button>
        <button
          type="button"
          onClick={() => decrement()}
        >
          自减
        </button>
        <button
          type="button"
          onClick={() => reset()}
        >
          重置
        </button>
        <button
          type="button"
          onClick={() => getUserInfo()}
        >
          请求
        </button>
      </div>
    );
  }
}

Counter.propTypes = {
  count: PropTypes.number,
  increment: PropTypes.func,
  decrement: PropTypes.func,
  reset: PropTypes.func,
  getUserInfo: PropTypes.func,
  userInfo: PropTypes.object,
};
